﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Telegnosis.Framework.UI.Util;

namespace CharacterTrailClient.Windows
{
    class MainFormControl
    {
        public static T GenerateForm<T>(Form parentForm) where T : FormBase, new()
        {
            var frm = new T();
            if (frm.ParentForm == null)
            {
                parentForm.AddOwnedForm(frm);
                frm.MdiParent = parentForm;
            }
            frm.Show();
            frm.Activate();
            return frm;
        }

        /// <summary>
        /// 创建游离的Form，没有父窗体的Form，也不显示
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GenerateFormFree<T>() where T : FormBase, new()
        {
            var frm = new T();
            return frm;
        }
    }
}
